package com.yoake.cine.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yoake.common.annotation.Log;
import com.yoake.common.core.controller.BaseController;
import com.yoake.common.core.domain.AjaxResult;
import com.yoake.common.enums.BusinessType;
import com.yoake.cine.domain.MovieCategory;
import com.yoake.cine.service.IMovieCategoryService;
import com.yoake.common.utils.poi.ExcelUtil;
import com.yoake.common.core.page.TableDataInfo;

/**
 * 电影类别管理Controller
 * 
 * @author yoake
 * @date 2025-03-21
 */
@RestController
@RequestMapping("/cine/category")
public class MovieCategoryController extends BaseController
{
    @Autowired
    private IMovieCategoryService movieCategoryService;

    /**
     * 查询电影类别管理列表
     */
    @PreAuthorize("@ss.hasPermi('cine:category:list')")
    @GetMapping("/list")
    public TableDataInfo list(MovieCategory movieCategory)
    {
        startPage();
        List<MovieCategory> list = movieCategoryService.selectMovieCategoryList(movieCategory);
        return getDataTable(list);
    }

    /**
     * 导出电影类别管理列表
     */
    @PreAuthorize("@ss.hasPermi('cine:category:export')")
    @Log(title = "电影类别管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MovieCategory movieCategory)
    {
        List<MovieCategory> list = movieCategoryService.selectMovieCategoryList(movieCategory);
        ExcelUtil<MovieCategory> util = new ExcelUtil<MovieCategory>(MovieCategory.class);
        util.exportExcel(response, list, "电影类别管理数据");
    }

    /**
     * 获取电影类别管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('cine:category:query')")
    @GetMapping(value = "/{movieCategoryId}")
    public AjaxResult getInfo(@PathVariable("movieCategoryId") String movieCategoryId)
    {
        return success(movieCategoryService.selectMovieCategoryByMovieCategoryId(movieCategoryId));
    }

    /**
     * 新增电影类别管理
     */
    @PreAuthorize("@ss.hasPermi('cine:category:add')")
    @Log(title = "电影类别管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MovieCategory movieCategory)
    {
        return toAjax(movieCategoryService.insertMovieCategory(movieCategory));
    }

    /**
     * 修改电影类别管理
     */
    @PreAuthorize("@ss.hasPermi('cine:category:edit')")
    @Log(title = "电影类别管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MovieCategory movieCategory)
    {
        return toAjax(movieCategoryService.updateMovieCategory(movieCategory));
    }

    /**
     * 删除电影类别管理
     */
    @PreAuthorize("@ss.hasPermi('cine:category:remove')")
    @Log(title = "电影类别管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{movieCategoryIds}")
    public AjaxResult remove(@PathVariable String[] movieCategoryIds)
    {
        return toAjax(movieCategoryService.deleteMovieCategoryByMovieCategoryIds(movieCategoryIds));
    }
}
